Movie controller components provide functions that handle movie controller actions. Your application must call these functions whenever an event occurs. Consider this event loop:
#if whatIsHandleEvent
while (! gDoneFlag) {
gResult = GetNextEvent (everyEvent, &gEventRec);
if (( MCIsPlayerEvent(gMCPlay, &gEventRec) == 0 )) {
if (gResult) {
/* player didn't handle the event */
HandleEvent(gEventRec);
}
}
}
#endif
#if 0
/* interface for application-defined routine: */
pascal Boolean MyPlayerFilter ( MovieController mc,
short* action, long* params);
#endif
If the movie controller component handles the event, your application can loop to wait for the next event. Otherwise, your application must take care of the event as part of its normal event handling.
Movie controller components support an action filter. You can instruct the filter to invoke a function in your application whenever actions occur. This action filter function can then perform specialized processing or refer the action back to the movie controller component. The actions supported by movie controller components are discussed in "Movie Controller Actions," which begins on Movie Controller Actions .
The MCIsPlayerEvent function lets you pass events to a movie controller component. The MCSetActionFilterWithRefCon function allows you to specify your action filter function for a movie controller.
You can use the MCDoAction function to request action processing from a movie controller.
If you use any Movie Toolbox functions to change the characteristics of a movie that is associated with a movie controller, you must inform the movie controller--use the MCMovieChanged function.
You can obtain information about the current state of the movie controller and its movie by calling the MCGetControllerInfo function.
The MCIsPlayerEvent function handles all events for a movie controller. Your application should call this function in its main event loop. Call MCIsPlayerEvent for each active movie controller until the event is handled.
This function returns a long integer indicating whether the movie controller component handled the event. The component sets this long integer to 1 if it handled the event. Your application should then skip the rest of its event loop and wait for the next event. The return value is 0 otherwise. Your application must then handle the event as part of its normal event processing.
The movie controller component does everything necessary to support the movie controller and its associated movie. For example, the component calls the Movie Toolbox's MoviesTask function for each movie. The movie controller component also handles suspend and resume events. It treats suspend events as deactivate requests and resume events as activate requests.
You can provide an action filter function that is called by the movie controller component. See "Application-Defined Function," which begins on Application-Defined Function , for details. The component calls your filter function after it decides to process a particular action, but before it actually does so. In this manner, your application can perform custom action processing for a movie controller. Set your action filter function with the MCSetActionFilterWithRefCon function, described on MCSetActionFilterWithRefCon .
pascal ComponentResult MCIsPlayerEvent (MovieController mc,
const EventRecord *e);
The MCIsPlayerEvent function returns a long integer indicating whether it handled the event. If the movie controller component handled the event, this function sets the returned value to 1. Your application should then skip the rest of its event loop and wait for the next event. If the component did not handle the event, the MCIsPlayerEvent function returns a value of 0. Your application must then handle the event.
Your application can use the MCDoAction function to invoke a movie controller component and have it perform a specified action.
pascal ComponentResult MCDoAction (MovieController mc,
short action, void *params);
For example, your application might define a menu item that stops all currently playing movies. When the user selects this menu item, your application could use the MCDoAction function to instruct each controller to stop playing. You would do so by specifying an mcActionPlay action with the parameters set to 0 to indicate that the controller should stop playing the movie.
The MCSetActionFilterWithRefCon function allows your application to establish an action filter function for a movie controller. The movie controller component calls your action filter function each time the component receives an action for its movie controller. Your filter function is then free to handle the action or to refer it back to the movie controller component. If you refer it back to the movie controller component, the component handles the action. See "Movie Controller Actions," which begins on Movie Controller Actions , for a description of the actions supported by movie controller components.
pascal ComponentResult MCSetActionFilterWithRefCon
(MovieController mc,
MCActionFilterWithRefConUPP blob,
long refCon);
Movie controller components allow your application to field movie controller actions. You define an action filter function in your application and assign it to a controller by calling the MCSetActionFilterWithRefCon function.
You can use the constants described in "Movie Controller Actions," which begins on Movie Controller Actions , to refer to movie controller actions.
If your filter function handles an action, you can handle the action in any way you desire. For example, your filter function could change the operation of movie controller buttons. More commonly, applications use the action filter function to monitor actions of the controller. For instance, your filter function might enable you to find out when the user clicks the play button, so that your application can enable appropriate menu selections. Alternatively, you can use the filter function to detect when the user resizes the movie.
If you use any Movie Toolbox functions that modify the movie in your action filter function, be sure to call the MCMovieChanged function (described on MCMovieChanged ).
Your application can use the MCGetControllerInfo function to determine the current status of a movie controller and its associated movie. You can use this information to control your application's menu highlighting.
pascal ComponentResult MCGetControllerInfo (MovieController mc,
long *someFlags);
The MCMovieChanged function lets you inform a movie controller component that your application has used the Movie Toolbox to change the characteristics of its associated movie.
pascal ComponentResult MCMovieChanged (MovieController mc,
Movie m);
Your application should be able to make most movie changes using the MCDoAction function (described on MCDoAction ). However, if your application uses Movie Toolbox functions to change the characteristics of a movie that is associated with a movie controller, you must inform the controller so that it can update itself accordingly. For instance, if your application changes the size of the movie without informing the movie controller component, the control portion of the controller may no longer be the proper size for the movie.